export function downloadFile(res,fname) {
    if (!res) {
      return;
    }
    let fileName = fname||'yangyang14.pdf';
    const { headers, data } = res;
    const { contentType } = headers;
    const contentDisposition = headers['content-disposition'];
    if (contentDisposition) {
      fileName = window.decodeURIComponent(contentDisposition.split('=')[1].split('?')[0]);
    }
    const blob = new Blob([data], { type: contentType }); // 设置文件类型excel
    if ('download' in document.createElement('a')) {
      const link = document.createElement('a');
      link.href = window.URL.createObjectURL(blob); // 创建下载的链接
      console.log('href', link.href);
      link.download = fileName; // 下载后文件名
      link.style.display = 'none';
      document.body.appendChild(link);
      link.click(); // 点击下载
      window.URL.revokeObjectURL(link.href); // 释放掉blob对象
      document.body.removeChild(link); // 下载完成移除元素
    } else {
      // IE10+下载
      window.navigator.msSaveBlob(blob, fileName);
    }
  }
  
  
  